package main

import "fmt"

/**
结构体map
*/
func main() {
	//定义结构体map
	m := make(map[string]studentsss)
	m["stu1"] = studentsss{101, "za", 22, "bj"}
	m["stu2"] = studentsss{101, "za", 22, "bj"}
	fmt.Println(m["stu1"]) //{101 za 22 bj}

	for i, v := range m {
		fmt.Println(i)
		fmt.Println(v)
		fmt.Println(v.name) //拿具体的属性值
	}

	n := make(map[int]studentsss)
	n[1] = studentsss{101, "za", 22, "bj"}
	n[2] = studentsss{101, "za", 22, "bj"}
	//根据键拿到对应得值
	fmt.Println(n[1]) //{101 za 22 bj}
	//删除对应的键的元素
	delete(n, 1)
	fmt.Println(n)

}

type studentsss struct {
	//这里不能加var关键字
	id   int
	name string
	age  int
	addr string
}
